Expand description

cqrs

A lightweight, opinionated CQRS and event sourcing framework targeting serverless architectures.

Command Query Responsibility Segregation (CQRS) is a pattern in Domain Driven Design that uses separate write and read models for application objects and interconnects them with events. Event sourcing uses the generated events as the source of truth for the state of the application.

Together these provide a number of benefits:

  • Removes coupling between tests and application logic allowing limitless refactoring.
  • Greater isolation of the aggregate.
  • Ability to create views that more accurately model our business environment.
  • A horizontally scalable read path.

Things that could be helpful:

Crates.io docs

Modules

An in-memory event store suitable for local testing.

Test provides a test framework for building a resilient test base around aggregates. A TestFramework should be used to build a comprehensive set of aggregate tests to verify your application logic.

Structs

This is the base framework for applying commands to produce events.

EventEnvelope is a data structure that encapsulates an event with along with it’s pertinent information. All of the associated data will be transported and persisted together.

Simple payload for an AggregateError::UserError. This payload implements Serialize with the intention of allowing the user to return this object as the response payload.

Enums

The base error for the framework.

Traits

In CQRS (and Domain Driven Design) an Aggregate is the fundamental component that encapsulates the state and application logic (aka business rules) for the application. An Aggregate is always an entity along with all objects associated with it.

Returns the aggregate and context around it that is needed when committing events

A DomainEvent represents any business change in the state of an Aggregate. DomainEvents are immutable and with event sourcing they are the source of truth.

The abstract central source for loading past events and committing new events.

Each CQRS platform should have one or more QueryProcessors where it will distribute committed events, it is the responsibility of the QueryProcessor to update any interested queries.

A Query is a read element in a CQRS system. As events are emitted multiple downstream queries are updated to reflect the current state of the system. A query may also be referred to as a ‘view’, the concepts are identical but ‘query’ is used here to conform with CQRS nomenclature.